<template>
    <div class="nav">
        <ul class="nav_box">
            
            <router-link to="/content" tag="div" class="wid">
                <li class="nav-title"><div class="tabtxt" :class="{active:curIndex==0}"><span>推荐音乐</span></div></li>
            </router-link>

            <router-link to="/hotSong" tag="div" class="wid" >
                <li class="nav-title"><div class="tabtxt" :class="{active:curIndex==1}"><span>热歌榜</span></div></li>
             </router-link>
             <router-link to="/search" tag="div" class="wid">
            <li class="nav-title"><div class="tabtxt" :class="{active:curIndex==2}"><span>搜索</span></div></li>
            </router-link>
        </ul>
    </div>
</template>
<script>
export default {
    data(){
        return {
            curIndex:0
        }
    },
    methods:{
        setCurIndex(fullPath){
            console.log(fullPath);
            if(fullPath=="/content"){
                this.curIndex=0;
                console.log(this.curIndex)
            }
            else if(fullPath=="/hotSong"){
                this.curIndex=1;
                console.log(this.curIndex)
            }
            else if(fullPath=="/search"){
                this.curIndex=2;
                console.log(this.curIndex)
            }
        }
    },
    watch:{
        $route(newFullPath){
        this.setCurIndex(this.$route.fullPath)
        }
    }
}
</script>
<style lang="scss" scoped>
.nav{
    z-index: 999;
    background: #ffffff;
    position: fixed;
    top: 64px;
    width: 100%;
    border-bottom:1px solid rgb(204, 204, 204);
}
.nav_box{
    display: flex;
    width: 100%;
    height: 40px;
    justify-content:space-around;
    align-items: center;
}
.nav-title{
    float: left;
    list-style: none;
    width: 100%;
    height: 100%;
    text-align: center;
    line-height: 40px;
    font-size: 15px;
    cursor: pointer;
}
.tabtxt{
   display: inline-block;
   position: relative;

   span{
       vertical-align: middle;
       
   }
   
}
.active{
       border-bottom:2px solid #d33a31;
       color: #d33a31;
}
.wid{
    width: 33.33%;
}
</style>
